<!--#
layout("/layouts/platform.html"){
#-->
<div id="app" v-cloak>
    <!--<div class="head">
        <div class="headone"><i class="el-icon-menu"></i><span>移交管理</span></div>
    </div>-->
    <el-tabs v-model="pageForm.type" ref="tabs" type="card" @tab-click="doSearch">
        <!--#if(@shiro.hasPermission("bus.ypxx.transfer.transferred")){#-->
        <el-tab-pane  name="transferred">
            <span slot="label">
                待移交
                <div v-if="transferredCount>0" class="badge badge-top bg-danger animated flash" ><span>{{transferredCount}}</span></div>
            </span>
        </el-tab-pane>
        <!--#}#-->
        <!--#if(@shiro.hasPermission("bus.ypxx.transfer.toReceived")){#-->
        <el-tab-pane  name="toReceived">
            <span slot="label">
                待接收
                <div v-if="toReceivedCount>0" class="badge badge-top bg-danger animated flash" ><span>{{toReceivedCount}}</span></div>
            </span>
        </el-tab-pane>
        <!--#}#-->
        <!--#if(@shiro.hasPermission("bus.ypxx.transfer.adReceived")){#-->
        <el-tab-pane  name="adReceived">
            <span slot="label">
                已接收
                <div v-if="adReceivedCount>0" class="badge badge-top bg-danger animated flash" ><span>{{adReceivedCount}}</span></div>
            </span>
        </el-tab-pane>
        <!--#}#-->
        <!--#if(@shiro.hasPermission("bus.ypxx.transfer.adWithdrawal")){#-->
        <el-tab-pane label="已退样" name="adWithdrawal"></el-tab-pane>
        <!--#}#-->
        <!--#if(@shiro.hasPermission("bus.ypxx.transfer.adReturn")){#-->
        <el-tab-pane label="已归还" name="adReturn"></el-tab-pane>
        <!--#}#-->
        <!--#if(@shiro.hasPermission("bus.ypxx.transfer.dispose")){#-->
        <el-tab-pane label="自行处置" name="dispose"></el-tab-pane>
        <!--#}#-->
    </el-tabs>
    <el-row class="header navbar bg-white">

        <div class="btn-group tool-button" style="line-height: 50px;">
            样品编号或名称：<el-input placeholder="样品编号或名称" v-trim v-model="pageForm.searchKeyword" size="mini"
                      style="width:180px;" clearable></el-input>
            <!--<el-select v-trim v-model="pageForm.lzzt" placeholder="流转状态" size="mini" style="width:180px;">
                <el-option key="" label="全部" value=""></el-option>
                <el-option v-for="item in allMap.lzztOptions" v-if="item.value" :key="item.value" :label="item.label"
                           :value="item.value">
                </el-option>
            </el-select>-->
            <el-button slot="append" icon="el-icon-search" size="mini" @click="doSearch" circle></el-button>
        </div>
    </el-row>
    <el-row class="el-table-container">
        <el-table :data="tableData" @sort-change='pageOrder' height="520" border size="small" header-align="center"
                  style="width: 100%" row-key="id" @selection-change="handleSelectionChange">
            <el-table-column fixed="left" prop="userOnline" label="操作" width="120" header-align="center"
                             align="center">
                <template slot-scope="scope">
                    <el-dropdown @command="dropdownCommand">
                        <el-button size="mini"><i class="ti-settings"></i><span class="ti-angle-down"></span>
                        </el-button>
                        <el-dropdown-menu slot="dropdown">
                            <template v-if="pageForm.type=='transferred' || pageForm.type=='adReceived'">
                                <el-dropdown-item divided :command="{type:'to',obj:scope.row,buType:'yijiao'}">移交
                                </el-dropdown-item>
                            </template>
                            <template v-if="pageForm.type=='toReceived'">
                                <el-dropdown-item divided :command="{type:'tojs',obj:scope.row,buType:'jieshou'}">接收
                                </el-dropdown-item>
                            </template>
                            <template v-if="pageForm.type=='adReceived'&& scope.row.lzzt == '1'">
                                <el-dropdown-item divided :command="{type:'to',obj:scope.row,buType:'tuiyang'}">退样
                                </el-dropdown-item>
                            </template>
                            <template v-if="pageForm.type=='adReceived' && scope.row.lzzt == '2'">
                                <el-dropdown-item divided :command="{type:'to',obj:scope.row,buType:'guihuan'}">归还
                                </el-dropdown-item>
                            </template>
                            <template>
                                <el-dropdown-item divided :command="{type:'detail',obj:scope.row}">详情
                                </el-dropdown-item>
                            </template>
                            <template>
                                <el-dropdown-item divided :command="{type:'createCirculation',obj:scope.row}">流转单
                                </el-dropdown-item>
                            </template>
                        </el-dropdown-menu>
                    </el-dropdown>
                </template>
            </el-table-column>
            <el-table-column fixed="left" sortable="custom" prop="ypbh" label="样品编号" width="150px;" header-align="center"
                             show-overflow-tooltip></el-table-column>
            <el-table-column fixed="left" sortable="custom" prop="bgbh" label="报告编号" width="150px;" header-align="center"
                             show-overflow-tooltip></el-table-column>
            <el-table-column sortable="custom" prop="username" label="登记人" width="120px;" header-align="center"  show-overflow-tooltip></el-table-column>
            <el-table-column prop="lzzt" label="流转状态" width="100px;" header-align="center"
                             show-overflow-tooltip>
                <template slot-scope="scope" ><span :class="'lzstatusCss-'+scope.row.lzzt"><i :class="'lzel-icon-'+scope.row.lzzt"/>{{getDict(scope.row.lzzt,allMap.lzztMap)}}</span></template>
            </el-table-column>
            <el-table-column prop="lzzt" label="接收状态" width="100px;" header-align="center" show-overflow-tooltip>
                <template slot-scope="scope" >
                    <span v-if="scope.row.status=='0'">待接收</span>
                    <span v-if="scope.row.status=='1'">接收</span>
                    <span v-if="scope.row.status=='-1'">拒收</span></template>
                </template>
            </el-table-column>
            <el-table-column sortable="custom" prop="ypmc" label="产品名称" width="150px;" header-align="center"
                             show-overflow-tooltip></el-table-column>
            <el-table-column sortable="custom" prop="jylx" label="检验类别" width="100px;" header-align="center" align="center"
                             show-overflow-tooltip>
                <template slot-scope="scope">{{getDict(scope.row.jylx,allMap.jylxMap)}}</template>
            </el-table-column>
            <el-table-column sortable="custom" prop="jyks" label="检验部门" width="100px;" header-align="center" align="center"
                             show-overflow-tooltip></el-table-column>
            <el-table-column prop="wtdw" label="委托单位" width="100px;" header-align="center" align="center"
                             show-overflow-tooltip></el-table-column>
            <el-table-column prop="ggxh" label="规格型号" width="100px;" header-align="center" align="center"
                             show-overflow-tooltip></el-table-column>
            <el-table-column prop="scrqpc" label="原编号/生产日期" width="120px;" header-align="center" align="center"
                             show-overflow-tooltip></el-table-column>
            <el-table-column prop="sb" label="商标" width="100px;" header-align="center" align="center"
                             show-overflow-tooltip></el-table-column>
            <el-table-column sortable="custom" prop="wcqx" label="完成期限" width="100px;" header-align="center" align="center"
                             show-overflow-tooltip></el-table-column>
            <el-table-column prop="" label="剩余时间" width="100px;" header-align="center" align="center"
                             show-overflow-tooltip>
                <template slot-scope="scope" ><span :id="'foot'+scope.$index">{{getDay(scope.row.wcqx,scope.$index)}}</span></template>
            </el-table-column>
        </el-table>
    </el-row>
    <el-row class="el-pagination-container">
        <el-pagination @size-change="pageSizeChange" @current-change="pageNumberChange"
                       :current-page="pageForm.pageNumber" :page-sizes="[10, 20, 30, 50]"
                       :page-size="pageForm.pageSize" layout="total, sizes, prev, pager, next, jumper"
                       :total="pageForm.totalCount">
        </el-pagination>
    </el-row>
    </el-dialog>
    <el-drawer :wrapperClosable="false" title="详情" :visible.sync="drawer" direction="rtl" size="80%"
               @opened="openIframe" destroy-on-close>
        <iframe id="iframeDetail" src="" width="100%" height="100%" frameborder="0" marginheight="0"></iframe>
    </el-drawer>
    <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="addDialogVisible" width="700px">
        <el-form :model="formData" ref="addForm" :rules="Rules" size="mini" label-width="140px">
            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item prop="ypbh" label="样品编号">
                        <el-link type="primary" size="mini" @click="dropdownCommand({type:'detail',obj:formData})">
                            {{formData.ypbh}}
                        </el-link>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item prop="sfty" label="是否退样">
                        <el-radio-group v-model="formData.sfty" size="mini" v-if="formData.lzzt==0">
                            <el-radio label="0">是</el-radio>
                            <el-radio label="1">否</el-radio>
                        </el-radio-group>
                        <span v-else>
                    {{formData.sfty==0?'是':'否'}}
                </span>
                    </el-form-item>
                </el-col>
                <el-col :span="12" v-if="formData.sfty==0">
                    <el-form-item v-if="formData.buType=='yijiao'" prop="tyzt"  label="退样要求">
                        <el-radio-group v-model="formData.tyzt" size="mini">
                            <el-radio-button label="原样" value="原样"></el-radio-button>
                            <el-radio-button label="残次" value="残次"></el-radio-button>
                            <el-radio-button label="报损" value="报损"></el-radio-button>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item v-else-if="formData.buType=='tuiyang'" prop="tyzt"  label="退样状态">
                        <el-radio-group v-model="formData.tyzt" size="mini">
                            <el-radio-button label="原样" value="原样"></el-radio-button>
                            <el-radio-button label="残次" value="残次"></el-radio-button>
                            <el-radio-button label="报损" value="报损"></el-radio-button>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item v-else prop="tyzt"  label="归还状态">
                        {{formData.tyzt}}
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item prop="yjsj" label="移交时间" v-if="formData.buType=='yijiao'">
                        <el-date-picker type="datetime" :picker-options="expireTimeOption" popper-class="hide-time" v-trim v-model="formData.yjsj" value-format="yyyy-MM-dd HH:mm:ss"
                                        style="width: 180px;"></el-date-picker>
                    </el-form-item>
                    <el-form-item prop="yjsj" label="退样时间"  v-if="formData.buType=='tuiyang'">
                        <el-date-picker type="datetime" :picker-options="expireTimeOption" popper-class="hide-time" v-trim v-model="formData.yjsj" value-format="yyyy-MM-dd HH:mm:ss"
                                        style="width: 180px;"></el-date-picker>
                    </el-form-item>

                </el-col>
                <el-col :span="12">
                    <el-form-item label ="备样数量" v-if="formData.buType=='yijiao'">
                        {{formData.bysl}} {{formData.unit}}
                    </el-form-item>

                </el-col>
                <el-col :span="12">
                    <el-form-item label="检样数量" v-if="formData.buType=='yijiao'">
                        {{formData.jysl}} {{formData.unit}}
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item prop="yjsl" label="移交数量">
                        <el-input-number maxlength="30" v-trim v-model="formData.yjsl" style="width:110px;"
                                  v-if="formData.buType=='yijiao'"></el-input-number>
                        <span v-else>{{formData.yjsl}}</span> {{formData.unit}}
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item prop="tysl" label="退样数量" v-if="formData.buType=='tuiyang' && formData.sfty==0">
                        <el-input-number maxlength="30" v-trim v-model="formData.tysl" style="width:110px;"></el-input-number> {{formData.unit}}
                    </el-form-item>
                    <el-form-item  label="退样数量" v-if="formData.buType=='guihuan'">
                        {{formData.tysl}} {{formData.unit}}
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item prop="bgbh" label="报告编号" v-if="formData.buType=='tuiyang'">
                        <el-input maxlength="30" v-trim v-model="formData.bgbh" style="width:180px;" @change="disBgbh"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12" v-if="formData.buType=='tuiyang' && formData.lzzt>0">
                    <el-form-item prop="jywcrq" label="检验完成日期">
                        <el-date-picker type="date" :picker-options="expireTimeOption" v-trim v-model="formData.jywcrq" value-format="yyyy-MM-dd" style="width: 180px;"></el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="24"  v-if="formData.buType=='tuiyang' && formData.lzzt>0">
                    <el-form-item prop="byczqk" label="试毕样品处理情况">
                        <el-input maxlength="75" v-trim v-model="formData.byczqk" type="textarea"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item prop="ghsl" label="归还数量" v-if="formData.buType=='guihuan'">
                        <el-input-number maxlength="30" v-trim v-model="formData.ghsl" style="width:110px;"></el-input-number> {{formData.unit}}
                    </el-form-item>
                    <el-form-item label="自行处置" v-if="formData.buType=='tuiyang' && formData.sfty==1">
                        <span>无需退样，请自行处置</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item prop="nextsprIds" label="接收人" v-if="formData.buType=='yijiao'">
                        <el-cascader v-model="formData.nextsprIds" :options="allMap.userOptions" ref="nextsprCascader" style="width:100%;"></el-cascader>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item prop="spyj" label="备注">
                        <el-input maxlength="200" v-trim v-model="formData.spyj" type="textarea" size="mini" rows="3"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <span slot="footer" class="dialog-footer">
                    <el-button @click="addDialogVisible = false">取 消</el-button>
                    <el-button type="primary" @click="doAdd">提 交</el-button>
                  </span>
    </el-dialog>

    <el-dialog :close-on-click-modal="false" title="样品接收" :visible.sync="jsDialogVisible" width="700px">
        <el-form :model="jsformData" ref="jsForm" :rules="jsRules" size="mini" label-width="120px">
            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item  label="样品编号">
                        <el-link type="primary" size="mini" @click="dropdownCommand({type:'detail',obj:{id:jsformData.jbxxId}})">
                            {{jsformData.ypbh}}
                        </el-link>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="是否退样">
                        {{jsformData.sfty==0?'是':'否'}}
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item v-if="jsformData.sfty==0 && jsformData.lzzt==1" label="退样要求">
                        {{jsformData.tyzt}}
                    </el-form-item>
                    <el-form-item v-if="jsformData.sfty==0 && jsformData.lzzt!=1" label="退样状态">
                        {{jsformData.tyzt}}
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="移交时间" v-if="jsformData.lzzt==1">
                        {{jsformData.lzAt}}
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="退样时间" v-if="jsformData.lzzt==2">
                        {{jsformData.lzAt}}
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="计划完成日期"  v-if="jsformData.lzzt==1">
                        {{jsformData.wcqx}}
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="备样数量" v-if="jsformData.lzzt==1">
                        {{jsformData.bysl}} {{jsformData.unit}}
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="检样数量" v-if="jsformData.lzzt==1">
                        {{jsformData.jysl}} {{jsformData.unit}}
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="移交数量" v-if="jsformData.lzzt==1">
                        {{jsformData.number}} {{jsformData.unit}}
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="退样数量" v-if="jsformData.lzzt==2">
                        {{jsformData.number}} {{jsformData.unit}}
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item prop="tysl" label="发起人">
                        {{jsformData.fqr}}
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item prop="tysl" label="接收人">
                        {{jsformData.nextspr}}
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item prop="tysl" label="备注">
                        {{jsformData.oldSpyj}}
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item prop="status" label="是否接收">
                        <el-radio-group v-model="jsformData.status" size="mini">
                            <el-radio label="1" border>接收</el-radio>
                            <el-radio label="-1" border>拒收</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
                <el-col :span="12" v-if="jsformData.status == 1">
                    <el-form-item prop="statusAt" label="接收时间"  >
                        <el-date-picker type="datetime" :picker-options="expireTimeOption" popper-class="hide-time" v-trim  v-model="jsformData.statusAt" value-format="yyyy-MM-dd HH:mm:ss"
                                        style="width: 180px;"></el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item prop="spyj" v-if="jsformData.status=='-1'" label="备注">
                        <el-input maxlength="200" v-trim v-model="jsformData.spyj" type="textarea" size="mini" rows="3"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <span slot="footer" class="dialog-footer">
                    <el-button @click="jsDialogVisible = false">取 消</el-button>
                    <el-button type="primary" @click="jsAdd">提 交</el-button>
                  </span>
    </el-dialog>
</div>
<script>
    new Vue({
        el: "#app",
        data: function () {
            var allMap = {
                jylxMap:${jylxMap},
                lzztMap:${lzztMap},
                userOptions: {}
            };
            return {
                allMap: allMap,
                tableData: [],
                menuOptions: [],
                pageForm: {lzzt: "", type: ""},
                title: "样品移交",
                headTitle: "",
                multipleSelection: [],
                drawer: false,
                deltailURL: "",
                formData: {},
                addDialogVisible: false,
                Rules: {
                    tyzt: [{required: true, message: '请选择退样状态！', trigger: ['blur', 'change']}],
                    yjsj: [{required: true, message: '请选择移交时间！', trigger: ['blur', 'change']}],
                    yjsl: [{required: true, message: '请输入移交数量！', trigger: ['blur', 'change']}],
                    tysl: [{required: true, message: '请输入退样数量！', trigger: ['blur', 'change']}],
                    ghsl: [{required: true, message: '请输入归还数量！', trigger: ['blur', 'change']}],
                    nextsprIds: [{required: true, message: '请选择接收人！', trigger: ['blur', 'change']}],
                    jywcrq:[{required: true, message: '请选择检验完成日期！', trigger: ['blur', 'change']}],
                    bgbh:[{required: true, message: '报告编号不能为空！', trigger: ['blur', 'change']}],
                    byczqk:[{required: true, message: '试毕样品处理情况不能为空！', trigger: ['blur', 'change']}],
                },

                jsformData: {spyj: ""},
                jsDialogVisible: false,
                jsRules: {
                    status: [{required: true, message: '请选择是否接收！', trigger: ['blur', 'change']}],
                    statusAt: [{required: true, message: '请选择接收时间！', trigger: ['blur', 'change']}],
                },
                transferredCount:0,
                toReceivedCount:0,
                adReceivedCount:0,
                expireTimeOption: {
                    disabledDate(time) {
                        return time.getTime() > Date.now(); // - 8.64e7 //如果没有后面的-8.64e7就是不可以选择今天的
                    },
                    selectableRange: '00:00:00 - ' + new Date().getHours() + ':' + (new Date().getMinutes() + 1) + ':00'

                },
            }
        },
        watch:{
            // 移交时间
            'formData.yjsj'(selectTime){
                const date = new Date(new Date(selectTime).setHours(0,0,0,0)).getTime()
                const today = new Date(new Date().setHours(0,0,0,0)).getTime()
                const time = new Date(new Date(selectTime)).getTime()
                const totime = new Date(new Date()).getTime()
                if(time >= totime){
                    this.formData.yjsj = sublime.formatDate({ date: new Date(), formatStr: 'yyyy-MM-dd HH:mm:ss' });
                }
                if (date >= today){
                    // 当选择的日期就是当天的时候，这个时候就要限制时间应当大于此时此刻的时分秒
                    this.expireTimeOption.selectableRange =  '00:00:00 - ' + new Date().getHours() + ':'+(new Date().getMinutes()+1)+':00'
                }else {
                    // 当选择的日期大于当天的时候，这时需要把时分秒的限制放开，否则不能选择
                    this.expireTimeOption.selectableRange = '00:00:00 - 23:59:59'
                }
                this.formData.yjsj = sublime.formatDate({ date: new Date(this.formData.yjsj), formatStr: 'yyyy-MM-dd HH:mm:ss' });
            },
            // 接收时间
            'jsformData.statusAt'(selectTime){
                const date = new Date(new Date(selectTime).setHours(0,0,0,0)).getTime()
                const today = new Date(new Date().setHours(0,0,0,0)).getTime()
                const time = new Date(new Date(selectTime)).getTime()
                const totime = new Date(new Date()).getTime()
                if(time >= totime){
                    this.jsformData.statusAt = sublime.formatDate({ date: new Date(), formatStr: 'yyyy-MM-dd HH:mm:ss' });
                }
                if (date >= today){
                    // 当选择的日期就是当天的时候，这个时候就要限制时间应当大于此时此刻的时分秒
                    this.expireTimeOption.selectableRange =  '00:00:00 - ' + new Date().getHours() + ':'+(new Date().getMinutes()+1)+':00'
                }else {
                    // 当选择的日期大于当天的时候，这时需要把时分秒的限制放开，否则不能选择
                    this.expireTimeOption.selectableRange = '00:00:00 - 23:59:59'
                }
                this.formData.statusAt = sublime.formatDate({ date: new Date(this.formData.statusAt), formatStr: 'yyyy-MM-dd HH:mm:ss' });
            }
        },
            methods: {
            /*handleClick(tab, event) {
                this.pageForm.pageSize = 0;
                this.pageData();
            },*/
            pageOrder: function (column) {//按字段排序
                this.pageForm.pageOrderName = column.prop;
                this.pageForm.pageOrderBy = column.order;
                this.pageData();
            },
            pageNumberChange: function (val) {//页码更新操作
                this.pageForm.pageNumber = val;
                this.pageData();
            },
            pageSizeChange: function (val) {//分页大小更新操作
                this.pageForm.pageSize = val;
                this.pageData();
            },
            pageData: function () {//加载分页数据
                var self = this;
                sublime.showLoadingbar();//显示loading
                $.post(base + "/platform/bus/ypxx/transfer/data", self.pageForm, function (data) {
                    sublime.closeLoadingbar();//关闭loading
                    if (data.code == 0) {
                        self.tableData = data.data.listPages.list;
                        self.pageForm.totalCount = data.data.listPages.totalCount;
                        self.transferredCount = data.data.transferredCount;
                        self.toReceivedCount = data.data.toReceivedCount;
                        self.adReceivedCount = data.data.adReceivedCount;
                    } else {
                        self.$message({
                            message: data.msg,
                            type: 'error'
                        });
                    }
                }, "json");
            },
            doSearch: function () {
                this.pageForm.pageNumber = 1;
                this.pageData();
            },
            getDict: function (val, map) {
                val = val + "";
                if (val != null && val != undefined && val != "" && map != null && map != undefined) {
                    var str = val.split(",");
                    var strname = "";
                    for (var a = 0; a < str.length; a++) {
                        strname += map[str[a]];
                        if (strname == null) {
                            alert(1)
                        }
                        if (a < (str.length - 1)) {
                            strname += "/";
                        }
                    }
                    return strname;
                }
                return "";
            },
            dropdownCommand: function (command) {//监听下拉框事件
                var self = this;
                if ("to" == command.type) {
                    $.post(base + "/platform/bus/ypxx/transfer/toDetail/" + command.obj.id, {}, function (data) {
                        if (data.code == 0) {
                            self.formData = data.data.obj;
                            self.formData.buType = command.buType;
                            if (self.formData.lzzt == 0) {
                                self.formData.sfty = "0";
                            }
                            //self.formData.jywcrq = new Date()+"";
                            if(nONull(data.data.lzxxObj)){
                                self.formData.oldLzxxId = data.data.lzxxObj.id;
                            }
                            self.allMap.userOptions = data.data.userOptions;
                            if(command.buType=='tuiyang' ){
                                self.formData.jywcrq = sublime.formatDate({ date: new Date(), formatStr: 'yyyy-MM-dd' });
                                if(nONull(self.formData.bgbh)){
                                    self.formData.oldBgbh = self.formData.bgbh;
                                }else{
                                    self.getBgbh(self.formData.id);
                                }
                                self.formData.tysl=self.formData.yjsl
                            }
                            self.formData = JSON.parse(JSON.stringify(self.formData))
                            self.addDialogVisible = true;//打开编辑窗口
                            if(command.buType=='tuiyang'){
                                if(self.formData.sfty == "0"){
                                    self.title="样品退样"
                                }else{
                                    self.title="自行处置"
                                }
                            }
                            else if(command.buType=='yijiao'){
                                self.title="样品移交"
                            }
                            else if(command.buType=='guihuan'){
                                self.title="样品归还"
                            }
                        } else {
                            self.$message({
                                message: data.msg,
                                type: 'error'
                            });
                        }
                    }, "json");
                }
                if ("tojs" == command.type) {
                    $.post(base + "/platform/bus/ypxx/transfer/toDetail/" + command.obj.id, {}, function (data) {
                        if (data.code == 0) {
                            self.jsformData = data.data.lzxxObj;
                            var jbxx = data.data.obj;
                            self.jsformData.buType = command.buType;
                            self.jsformData.sfty = jbxx.sfty;
                            self.jsformData.tyzt = jbxx.tyzt;
                            self.jsformData.bysl = jbxx.bysl;
                            self.jsformData.jysl = jbxx.jysl;
                            self.jsformData.unit = jbxx.unit;
                            self.jsformData.oldSpyj = data.data.lzxxObj.spyj;
                            self.jsformData.spyj = "";
                            self.jsformData.status = "1";
                            self.jsformData.fqr = data.data.fqr;
                            self.jsformData.wcqx = jbxx.wcqx;
                            self.jsformData.statusAt = jbxx.yjsj;
                            //self.jsformData.id = jbxx.id;
                            self.jsformData = JSON.parse(JSON.stringify(self.jsformData))
                            self.jsDialogVisible = true;//打开编辑窗口
                        } else {
                            self.$message({
                                message: data.msg,
                                type: 'error'
                            });
                        }
                    }, "json");
                    self.jsDialogVisible = true;//打开编辑窗口
                }
                if ("detail" == command.type) {
                    this.drawer = true;
                    this.deltailURL = "/platform/bus/ypxx/jbxx/detail/" + command.obj.id;
                }
                if ("createCirculation" == command.type) {
                    sublime.showLoadingbar();//显示loading
                    $.post(base + "/platform/bus/ypxx/transfer/createCirculation/" + command.obj.id, {}, function (data) {
                        sublime.closeLoadingbar();//关闭loading
                        if (data.code == 0) {
                            self.$message({
                                message: data.msg,
                                type: 'success'
                            });
                            self.drawer = true;
                            var WOPISrc = "${AppDomain!}/platform/wopi/files/" + command.obj.id + "lzd.docx";
                            self.deltailURL = "${AppOfficeDomain!}/wv/wordviewerframe.aspx?wdAccPdf=1&WOPISrc=" + WOPISrc+"&_="+Math.floor(Math.random()*100000);
                        } else {
                            self.$message({
                                message: data.msg,
                                type: 'error'
                            });
                        }
                    }, "json");
                }
            },
            getBgbh:function(id){
                var self = this;
                $.post(base + "/platform/bus/ypxx/jbxx/findBgbh",{id:id}, function (data) {
                    if (data.code == 0) {
                        self.formData.bgbh = data.data;
                        self.formData.oldBgbh = data.data;
                        self.formData = JSON.parse(JSON.stringify(self.formData))
                    } else {
                        self.$message({
                            message: data.msg,
                            type: 'error'
                        });
                    }
                }, "json");
            },
            disBgbh:function(){
                var self = this;
                if(nONull(self.formData.bgbh)) {
                    $.post(base + "/platform/bus/ypxx/jbxx/disBgbh", {
                        bgbh: self.formData.bgbh,
                        id: self.formData.id
                    }, function (data) {
                        if (data.code != 0) {
                            self.$message({message: data.msg, type: 'error'});
                            self.formData.bgbh = self.formData.oldBgbh;
                            self.formData = JSON.parse(JSON.stringify(self.formData))
                        }
                    }, "json");
                }
            },
            jsAdd: function () {
                var self = this;
                self.$refs["jsForm"].validate(function (valid) {
                    if (valid) {
                        $.post(base + "/platform/bus/ypxx/transfer/jsDo", self.jsformData, function (data) {
                            if (data.code == 0) {
                                self.$message({
                                    message: data.msg,
                                    type: 'success'
                                });
                                self.jsDialogVisible = false;
                                self.pageData();
                            } else {
                                self.$message({
                                    message: data.msg,
                                    type: 'error'
                                });
                            }
                        }, "json");
                    }
                });
            },
            doAdd: function () {
                var self = this;

                //return ;
                self.$refs["addForm"].validate(function (valid) {
                    if (valid) {
                        if (nONull(self.formData.nextsprIds)) {
                            self.formData.nextsprIds = self.formData.nextsprIds.join(",");
                            self.formData.nextspr = self.$refs['nextsprCascader'].getCheckedNodes()[0].label;
                        }
                        $.post(base + "/platform/bus/ypxx/transfer/lzxxDo", self.formData, function (data) {
                            if (data.code == 0) {
                                self.$message({
                                    message: data.msg,
                                    type: 'success'
                                });
                                self.addDialogVisible = false;//打开编辑窗口
                                self.pageData();
                            } else {
                                self.formData.nextsprIds = self.formData.nextsprIds.split(",");
                                self.$message({
                                    message: data.msg,
                                    type: 'error'
                                });
                            }
                        }, "json");
                    }
                });
            },
            openIframe: function () {
                $("#iframeDetail").attr("src", this.deltailURL);
            },
            handleClose: function () {
                this.drawer = false;
            },
            handleSelectionChange: function (val) {
                this.multipleSelection = val;
            },
            getDay(day,index){
                if(day){
                    const today = new Date();
                    const inputDate = new Date(day);
                    const diffTime = inputDate-today;
                    const diffDays = Math.abs((diffTime / (1000 * 60 * 60 * 24)).toFixed(0));
                    if(diffTime<0&&diffDays>0){
                        $("#foot"+index).css("color","red");
                        return "逾期："+diffDays+"天";
                    }else{
                        return "剩余："+diffDays+"天";
                    }
                }else{
                    return "";
                }
            }
        },
        created: function () {
            this.$nextTick(() => {
                /*const firstTabPane = this.$refs.tabs;
                this.pageForm.type = firstTabPane;*/
                // 你现在可以操作这个DOM元素了
                const  firstTabPane = [];
                <!--#if(@shiro.hasPermission("bus.ypxx.transfer.transferred")){#-->
                firstTabPane.push("transferred");
                <!--#}#-->
                <!--#if(@shiro.hasPermission("bus.ypxx.transfer.toReceived")){#-->
                firstTabPane.push("toReceived");
                <!--#}#-->
                <!--#if(@shiro.hasPermission("bus.ypxx.transfer.adReceived")){#-->
                firstTabPane.push("adReceived");
                <!--#}#-->
                <!--#if(@shiro.hasPermission("bus.ypxx.transfer.adReturn")){#-->
                firstTabPane.push("adReturn");
                <!--#}#-->
                <!--#if(@shiro.hasPermission("bus.ypxx.transfer.dispose")){#-->
                firstTabPane.push("dispose");
                <!--#}#-->
                this.pageForm.type = firstTabPane[0];
                this.doSearch();
            });
        }
    });

    function nONull(val) {
        if (val != null && val != undefined && val != "") {
            return true;
        } else {
            return false;
        }
    }
</script>
<style>
    .el-picker-panel.hide-time {
        .el-button--text.el-picker-panel__link-btn {
            display: none;
        }
    }

</style>
<!--#
}
#-->
